﻿using Crawler.Core.Analyzer;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class CoreService
    {
        public static IServiceCollection AddCores(this IServiceCollection services)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            foreach (var type in assembly.GetTypes())
            {
                if (!type.FullName.StartsWith("Crawler.Core")) continue;
                if (type.IsInterface) continue;
                services.AddTransient(type);
            }
            //注册解析器服务
            AnalyzerManager.Register(services);

            return services;
        }
    }
}
